package com.jeesite.modules.fl.utils;


import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import com.jeesite.modules.sys.entity.Area;
import com.jeesite.modules.sys.entity.DictData;

public class DictProperties {
	
	private Properties properties;
	private static DictProperties dictProperties;
	
	private DictProperties(){
		properties = new Properties();
		try {
			InputStream in = this.getClass().getClassLoader().getResourceAsStream("config/dict_en.properties");
			properties.load(in);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static DictProperties getInstatnce(){
		if( dictProperties == null){
			dictProperties = new DictProperties();
		}
		return dictProperties;
	}
	
	public Properties getProperties(){
		return properties;
	}
	
	public String getDictLabel(DictData data){
		return properties.getProperty(data.getDictType() + "." + data.getDictValue());
	}
	
	public String getAreaLabel(Area data){
		return properties.getProperty("area." + data.getAreaCode());
	}
	
	public static void main(String[] args) throws Exception{
		DictData data = new DictData();
		data.setDictType("fl_appointment_status");
		data.setDictValue("2");
		System.out.println(DictProperties.getInstatnce().getDictLabel(data));
	}

}
